/*
 * auth_cfg.h
 *
 *  Created on: Dec 13, 2013
 *      Author: killerg
 */

#ifndef AUTH_CFG_H_
#define AUTH_CFG_H_


#include "share/cfg_file.h"

struct auth_cfg_t {
    bool init(const char* prefix) {
        cfg_file_t file;
        if (!file.load("auth.txt", prefix))
            return false;

        ListenLogonIp        = file.get_str("listen_logon_ip", "0.0.0.0");
        ListenLogonPort      = file.get_int("listen_logon_port", 8000);
        ListenConsoleIp      = file.get_str("listen_console_ip", "0.0.0.0");
        ListenConsolePort    = file.get_int("listen_console_port", 9009);
        DbHost               = file.get_str("db_host", "");
        DbBucket             = file.get_str("db_bucket", "" );
        LogDbHost            = file.get_str("log_db_host", "");
        LogDbBucket          = file.get_str("log_db_bucket", "" );
        MaxCachedAccount	 = file.get_int("max_cached_account", 1000000 );
        Test                 = file.get_bool("test", false );
        EnableBill			 = file.get_bool("enable_bill", true);

        if (DbHost.empty()
         || DbBucket.empty()
         || LogDbHost.empty()
         || LogDbBucket.empty())
            return false;


        return true;
    }
    void destroy() {
    }

    std::string ListenLogonIp;
    int32_t ListenLogonPort;
    std::string ListenConsoleIp;
    int32_t ListenConsolePort;
    std::string DbHost;
    std::string DbBucket;
    std::string LogDbHost;
    std::string LogDbBucket;
    int32_t MaxCachedAccount;
    bool Test;
    bool EnableBill;
};



#endif /* AUTH_CFG_H_ */
